import React from 'react'
import PropTypes from 'prop-types'

export default function ChildComp(props) { // props: 包含组件标签属性的对象
  return (
    <div style={{background: '#aaaaaa'}}>
      <h2>ChildComp</h2>
      <p>num: {props.num}</p>
      <button onClick={() => props.increment2(2)}>加2</button>
    </div>
  )
}
ChildComp.propTypes = {
  num: PropTypes.number.isRequired,
  increment2: PropTypes.func.isRequired,
}
